<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/9/14
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>ERP系统 - 房租信息管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/lib/font-awesome/css/font-awesome.css">
</head>
<body>
    <h3>房租信息管理</h3>
    <div class="actions">
        <shiro:hasPermission name="sys:rent:add">
            <div>
                <a class="btn btn-primary" href="rentadd">添加房租信息</a>
            </div>
        </shiro:hasPermission>
        <shiro:hasPermission name="sys:rent:select">
            <form  action="select">
                <select name="field">
                    <option value="rId">房租序号</option>
                    <option value="hId">房子序号</option>
                    <option value="lId">租户序号</option>
                </select>
                <input type="text" name="ID" placeholder="输入关键字查询" value="${sessionScope.selId}">
                <input type="submit" value="搜索">
            </form>
        </shiro:hasPermission>

    </div>

    <table class="list">
        <tr>
            <th>房租序号</th>
            <th>房子序号</th>
            <th>房子地址</th>
            <th>房子面积</th>
            <th>租户序号</th>
            <th>租户姓名</th>
            <th>租户手机号</th>
            <th>租户身份证号</th>
            <th>房租总额</th>
            <th>房租支付时间</th>
            <th>备注</th>

            <th>操作</th>

        </tr>
        <c:forEach var="rent" items="${pageInfo.list}" varStatus="status">
            <tr>
                <td>${rent.rId}</td>

                <td>${rent.house.hId}</td>
                <td>${rent.house.hAddress}</td>
                <td>${rent.house.hAcreage}</td>
                <td>${rent.lessee.lId}</td>

                <td>${rent.lessee.lName}</td>
                <td>${rent.lessee.lTel}</td>
                <td>${rent.lessee.lIdcard}</td>

                <td>${rent.rMoney}</td>
                <td>${rent.rTime}</td>
                <td>${rent.rRemark}</td>

                <td>
                    <a class="fa fa-info" title="详情" href="rentdetail?rid=${rent.rId}">详情</a>
                    &nbsp;&nbsp;
                    <shiro:hasPermission name="sys:rent:update">
                        <a class="fa fa-pencil" title="编辑" href="rentedit?rid=${rent.rId}">编辑</a>
                    </shiro:hasPermission>
                   <shiro:hasPermission name="sys:rent:delete">
                       &nbsp;&nbsp;
                       <a class="fa fa-remove" title="删除" href="rentdelete?rid=${rent.rId}" onclick="confirmDelete(1)">删除</a>
                   </shiro:hasPermission>
                </td>
            </tr>
        </c:forEach>


    </table>
    <div class="pager-info">
        <div>共有 ${pageInfo.total} 条记录，第 ${pageInfo.pageNum}/${pageInfo.pages} 页 </div>
        <div>
            <ul class="pagination">
                <li class="paginate_button previous disabled }">
                    <a <c:if test="${sessionScope.selId == null}">
                        href="rentlist?pn=${pageInfo.hasPreviousPage?pageInfo.prePage:1}"
                    </c:if>
                            <c:if test="${sessionScope.selId != null}">
                                href="select?pn=${pageInfo.hasPreviousPage?pageInfo.prePage:1}&field=${sessionScope.field}&ID=${sessionScope.selId}"
                            </c:if>
                            >上一页</a>
                </li>
                <c:forEach begin="1" end="${pageInfo.pages}"  var="page">
                    <li class="${pageInfo.pageNum==page?'paginate_button active':''}"><a <c:if test="${sessionScope.selId == null}">
                        href="rentlist?pn=${page}"
                    </c:if>
                            <c:if test="${sessionScope.selId != null}">
                                href="select?pn=${page}&field=${sessionScope.field}&ID=${sessionScope.selId}"
                            </c:if>>${page}</a></li>
                </c:forEach>
                <li class="paginate_button next disabled">
                    <a <c:if test="${sessionScope.selId == null}">
                        href="rentlist?pn=${pageInfo.hasNextPage ? pageInfo.nextPage:pageInfo.pages}"
                    </c:if>
                            <c:if test="${sessionScope.selId != null}">
                                href="select?pn=${pageInfo.hasNextPage ? pageInfo.nextPage:pageInfo.pages}&field=${sessionScope.field}&ID=${sessionScope.selId}"
                            </c:if>
                            >下一页</a>
                </li>
            </ul>
        </div>
    </div>
    <script src="${pageContext.request.contextPath}/lib/jquery/jquery.js"></script>
    <script>
        function confirmDelete(id){
            if (confirm("确定要删除吗？")) {
                alert('发送删除请求，刷新页面（不要异步）');
            }
            return false;
        }
    </script>
</body>
</html>
